package jiakuang;

import java.util.ArrayList;
import java.util.List;

public class text {
    public static void main(String[] args) {
        learn4 news=new learn4(1,"火山爆发","zhuyu");
        learn4 news1=new learn4(2,"疫情爆发","yuzhu");
        learn4 news2=new learn4(3,"战争爆发","xom");
        learn4 news3=new learn4(4,"粮食危机爆发","zu");
        //创建容器:Arraylist对象实例化
        List List=new ArrayList();
        List.add(news);
        List.add(news1);
        List.add(news2);
        List.add(news3);
        System.out.println("增");
for(int i=0;i<List.size();i++) {
    learn4 te = (learn4) List.get(i);
    System.out.println(te.getNewsName());
}
System.out.println();
System.out.println("删");
List.remove(2);
for(int i=0;i<List.size();i++){
    learn4 te=(learn4) List.get(i);
    System.out.println(te.getNewsName());

}
List.set(2,news2);
System.out.println();
System.out.println("改");
for(int i=0;i<List.size();i++){
    learn4 te=(learn4) List.get(i);
    System.out.println(te.getNewsName());


}

    }
}
